package com.qzl.feiq.strategy.impl;

import com.qzl.feiq.annotation.ReceiveType;
import com.qzl.feiq.config.FeiQCache;
import com.qzl.feiq.enu.UserActionTypeEnum;
import com.qzl.feiq.message.Message;
import com.qzl.feiq.strategy.Receive;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

/**
 * 离线的广播消息
 */
@Slf4j
@ReceiveType(command = 6291458)
public class IpmsgBrExitImpl implements Receive {
    /**
     * 离线不需要回复消息，将现有用户剔除在线列表
     *
     * @param channel
     */
    @Override
    public void receiveMsg(Channel channel, Message oldMessage) {
        log.info("用户{}下线",oldMessage);
        FeiQCache.onlineUsers.remove(oldMessage.getFromUserIp());
        FeiQCache.userQueue.add(UserActionTypeEnum.logout);
    }
}
